#include<iostream>
#include<iomanip>
using namespace std;
const int N = 20;
int arr[N][N];
int n;
int main()
{
	while (cin >> n, n) {
		memset(arr, 0, sizeof(arr));
		int k = 1;
		int up = 0;
		int down = n - 1;
		int left = 0;
		int right = n - 1;
			for (int i = left; i <= right; i++) {
				arr[up][i] = k++;
			}
			for (int i = up + 1; i <= down; i++) {
				arr[i][right] = k++;
			}
			for (int i = right - 1; i >= left ; i--) {
				arr[down][i] = k++;
			}
			for (int i = down - 1; i > up; i--) {
				arr[i][left] = k++;
			}
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				if (arr[i][j] == 0) {
					cout << setw(3) << " ";
				}
				else {
					cout << setw(3) << arr[i][j];
				}
			}
			cout << endl;
		}
	}
	return 0;
}